package io.github.syske.springbootjdbcmybatisdemo.call;

import java.sql.*;

public class OracleFunctionExample {

    public static void main(String[] args){
        String url = "jdbc:oracle:thin:@127.0.0.1:1521/MWMS";
        String user = "std_mwms_whqr";
        String password = "hsbk_feng_whqr";
        try (Connection conn = DriverManager.getConnection(url, user, password)) {
            String sql = "{ ? = call F_Get_PK(?, ?,?) }";
            try (CallableStatement stmt = conn.prepareCall(sql)) {
                stmt.registerOutParameter(1, Types.VARCHAR); // 输出参数类型为INTEGER
                stmt.setString(2, "op_op_code"); // 第一个输入参数
                stmt.setString(3, "1"); // 第二个输入参数
                stmt.setInt(4, 1); // 第二个输入参数

                stmt.execute();

                String result = stmt.getString(1);
                System.out.println("The result is: " + result);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}


